<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>计算器</title>
</head>
<body>
	<h2>
		计算器
	</h2>
	<p>
		整数1:<input type="text" id="a" />
	</p>
	
	<p>
		整数2:<input type="text" id="b" />
	</p>
	
	<p>
		<button onclick="up(1)">相加</button>
		<button onclick="up(2)">相减</button>
		<button onclick="up(3)">相乘</button>
		<button onclick="up(4)">相除</button>
	</p>
	<p>
		结果 :<input type="text" id="c" />
	</p>
	<script type="text/javascript">
			
		function up(n){
			var a = document.querySelector("#a");
			a = a.value;
			a = Number(a);
			var b = document.querySelector("#b");
			b = b.value;
			b = Number(b);
			
			
			
			
			if(n==1){
			document.querySelector("#c").value = a + b;
			}
			if(n==2){
			document.querySelector("#c").value = a - b;
			}
			if(n==3){
			document.querySelector("#c").value = a * b;
			}
			if(n==4){
			document.querySelector("#c").value = a / b;
			}
		}
		
	</script>
</body>
</html>